/**0
 * 商品管理接口
 */
import {request} from '@/utils/reequest'
// 商品分类数据列表
export const getCategories =params =>{
  return request({
    method:'GET',
    url:'categories',
    params
  })
}
// 添加分类
export const postCategories =params =>{
  console.log(params, '')
  return request({
    method:'POST',
    url:'categories',
    data:{
      cat_pid:params.cat_pid,
      cat_name:params.cat_name,
      cat_level:params.cat_level
    }
  })
}
// 删除分类
export const deleteCategoriesId = ID =>{
  console.log(ID, '')
  return request({
    method:'delete',
    url:`categories/${ID}`
  })
}
// 编辑提交分类
export const putCategoriesId = (ID,data) =>{
  return request({
    method:'put',
    url:`categories/${ID}`,
    data
  })
}
//分类参数管理
//1. 参数列表
export const getCategoriesId = (ID,params) =>{
  return request({
    method:'GET',
    url:`categories/${ID}/attributes`,
    params
  })
}
//2.添加动态参数或者静态属性
export const postCategoriesId = (ID,params) =>{
  return request({
    method:'POST',
    url:`categories/${ID}/attributes`,
    data:{
      attr_name:params.attr_name,
      attr_sel:params.attr_sel
    }
  })
}
// 3.删除参数
export const deleteCategoriesIdAttrid = (ID,attrId) =>{
  return request({
    method:'delete',
    url:`categories/${ID}/attributes/${attrId}`
  })
}
// 4.根据 ID 查询参数
export const getCategoriesAttrId = (ID,attrId,attr_sel) =>{
  return request({
    method:'GET',
    url:`categories/${ID}/attributes/${attrId}`,
    data:{
      attr_sel:attr_sel
    }
  })
}
//5.编辑提交参数
export const putCategoriesAttrId = (sel,ID,attrId,params) =>{
  return request({
    method:'put',
    url:`categories/${ID}/attributes/${attrId}`,
    data:{
      attr_name:params.attr_name,
      attr_sel:sel
    }
  })
}
// 1.商品列表数据
export const getGoods = params =>{
  return request({
    method:'GET',
    url:'goods',
    params
  })
}
// 2.删除商品
export const deleteGoodsId = ID =>{
  return request({
    method:'delete',
    url:`goods/${ID}`
  })
}
